home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / DockStrip / MoreInterfaceLib / RemoteAccessInterface.h < prev   
Encoding:
C/C++ Source or Header  |  2000-06-24  |  14.1 KB  |  356 lines

  1. /*
  2.     File:        RemoteAccessInterface.h
  3.  
  4.     Contains:    Interface for making remote access calls.
  5.  
  6.     Written by:    Quinn (conversion to Universal Interfaces 3.2 format)
  7.  
  8.     Copyright:    Copyright © 1991-1998 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <1>     22/4/99    Quinn   First checked in.
  13. */
  14.  
  15. #ifndef __REMOTEACCESSINTERFACE__
  16. #define __REMOTEACCESSINTERFACE__
  17.  
  18. #ifndef __TYPES__
  19. #include <Types.h>
  20. #endif
  21. #ifndef __FILES__
  22. #include <Files.h>
  23. #endif
  24. #ifndef __APPLETALK__
  25. #include <AppleTalk.h>
  26. #endif
  27.  
  28. #if PRAGMA_ONCE
  29. #pragma once
  30. #endif
  31.  
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35.  
  36. #if PRAGMA_IMPORT
  37. #pragma import on
  38. #endif
  39.  
  40. #if PRAGMA_STRUCT_ALIGN
  41.     #pragma options align=mac68k
  42. #elif PRAGMA_STRUCT_PACKPUSH
  43.     #pragma pack(push, 2)
  44. #elif PRAGMA_STRUCT_PACK
  45.     #pragma pack(2)
  46. #endif
  47.  
  48. /* **** These callbacks are yet to be Universal Interfaced... **** */
  49.  
  50. typedef     pascal void (*UserStatusProcPtr)(UInt8 *, UInt8 *);
  51. typedef     pascal long (*PacketFilterProcPtr)(UInt8 *, UInt32, UInt32, UInt8 *, UInt32);
  52. typedef     pascal void (*RemmaperProcPtr)(UInt32, UInt32, UInt32, UInt8 *, UInt8 *);
  53. typedef     pascal void (*CallBackHookProcPtr)(UInt8 *, UInt32);
  54. typedef     pascal void (*CallBackCompHookProcPtr)(UInt8 *);
  55. typedef     pascal UInt32 (*NetValidProcPtr)(UInt8 *,AddrBlock);
  56.  
  57.  
  58. #define REMOTEACCESSNAME         "\pRemote Access"
  59. #define REMOTEACCESSID            'strm'                    // *** NOTE: "Network Extension" uses this id for its _Gestalt call
  60.  
  61. #define gestaltRemoteAccessAttr    REMOTEACCESSID
  62. #define gestaltRemoteAccessExists    0
  63.  
  64. #define gestaltRemoteAccessCallOnly    1                    /* Remote Access Client */
  65. #define gestaltRemoteAccessMPServer    2                    /* Remote Access multi-port server */
  66. #define gestaltRemoteAccessVers2    3                    /* ARA 2.0 features are available */
  67.  
  68. #define MAXSTATUSMSGSIZE        256
  69. #define USERNAMESIZE            34
  70. #define PASSWORDSIZE            8
  71. #define PASSWORDBUFSIZE            PASSWORDSIZE+1
  72.  
  73. #define TIME_UNLIMITED            0xffffffff                /* indicates unlimited time allowed on connection */
  74.  
  75.  
  76. #define ctlir_getConnectInfo 0x01                        /* will get connect info if address is remote */
  77. #define ctlir_disposeConnectInfo 0x02                    /* will dispose info in connectInfoPtr properly */
  78.  
  79.  
  80. /* control codes
  81. */
  82. #define RAM_EXTENDED_CALL                23                /* make an extended call (use TRemoteAccessParamBlock)    */
  83.  
  84. /* extended codes (must have control code set to RAM_EXTENDED_CALL)
  85. */
  86. /* the first group of calls can be issued without doing a load */
  87. #define CmdRemoteAccess_Load            1                /* loads main section of remote access */
  88. #define CmdRemoteAccess_Unload            2                /* unloads main section */
  89. #define CmdRemoteAccess_PassWordMunger    6                /* create a munged password */
  90. #define CmdRemoteAccess_GetCodeHooks    7                /* get code hooks */        
  91.  
  92. /* calls that will not work until CmdRemoteAccess_Load has been done */
  93. #define    CmdRemoteAccess_DoConnect                40                /* main thread only */
  94. #define CmdRemoteAccess_Disconnect                42                /* disconnect */
  95. #define CmdRemoteAccess_Status                    45                /* get status information */
  96. #define CmdRemoteAccess_IsAddressRemote            53                /* main thread only when getting/setting connect pb info */                        
  97.  
  98. /* Remote Access errors */
  99. #define ERR_BASE                        -5800
  100.  
  101. #define ERR_NOTCONNECTED                (ERR_BASE-0)
  102. #define ERR_CONNECTIONABORTED            (ERR_BASE-1)
  103. #define ERR_ALREADYCONNECTED            (ERR_BASE-2)
  104. #define ERR_COMMANDALREADYINPROGRESS    (ERR_BASE-3)
  105. #define ERR_BADVERSION                    (ERR_BASE-4)
  106. #define ERR_INSHUTDOWN                    (ERR_BASE-5)
  107. #define ERR_CONNECTIONABORTING            (ERR_BASE-6)
  108. #define ERR_ALREADYENABLED                (ERR_BASE-7)
  109. #define ERR_ZONEBUFBADSIZE                (ERR_BASE-8)
  110. #define ERR_CONNECTTIMEDOUT                (ERR_BASE-9)
  111. #define ERR_CONNECTUSERTIMEDOUT            (ERR_BASE-10)
  112. #define    ERR_BADPARAMETER                (ERR_BASE-11)
  113. #define    ERR_NOMULTINODE                    (ERR_BASE-12)
  114. #define    ERR_ATALKNOTACTIVE                (ERR_BASE-13)
  115. #define    ERR_NOCALLBACKSUPPORT            (ERR_BASE-14)
  116. #define    ERR_NOTOPENEDBYTHISPB            (ERR_BASE-15)
  117. #define ERR_NOGLOBALS                    (ERR_BASE-16)
  118. #define ERR_NOSMARTBUFFER                (ERR_BASE-17)
  119. #define ERR_BADATALKVERS                (ERR_BASE-18)
  120. #define ERR_VLD8_CONNECT                0
  121. #define ERR_VLD8_CALLBACK                (ERR_BASE-19)
  122. #define ERR_VLD8_BADVERSION                (ERR_BASE-20)
  123. #define ERR_VLD8_BADUSER                (ERR_BASE-21)
  124. #define ERR_VLD8_BADPASSWORD            (ERR_BASE-22)
  125. #define ERR_VLD8_BADLINK                (ERR_BASE-23)
  126. #define    ERR_VLD8_NOCALLBACKALLOWED        (ERR_BASE-24)
  127. #define    ERR_VLD8_ALLCBSERVERSBUSY        (ERR_BASE-25)
  128. #define    ERR_VLD8_GUESTNOTALLOWED        (ERR_BASE-26)
  129. #define ERR_VLD8_SERVERISIMPOSTER        (ERR_BASE-27)
  130. #define ERR_VLD8_LOGINNOTENABLED        (ERR_BASE-28)
  131. #define ERR_REMOTEPORTALREADYEXISTS        (ERR_BASE-29)
  132. #define ERR_OPENNOTALLOWED                (ERR_BASE-30)
  133. #define ERR_NOUSERSANDGROUPS            (ERR_BASE-31)
  134. #define ERR_PORTSHUTDOWN                (ERR_BASE-32)
  135. #define ERR_PORTDOESNOTEXIST            (ERR_BASE-33)
  136. #define ERR_PWNEEDEDFORENABLE            (ERR_BASE-34)
  137. #define ERR_DAMAGED                        (ERR_BASE-35)
  138. #define ERR_NETCONFIGCHANGED            (ERR_BASE-36)
  139. /* 2.0 and above only… */
  140. #define    ERR_NOSUPPORT_ATREMOTE            (ERR_BASE-37)
  141. #define ERR_CONFLICTING_REQUEST            (ERR_BASE-38)
  142. #define    ERR_VLD8_INVALIDAUTHMETHOD        (ERR_BASE-39)
  143. #define    ERR_VLD8_CONTINUE                (ERR_BASE-40)
  144. #define    ERR_PWCHANGECANCEL                (ERR_BASE-41)
  145. #define ERR_VLD8_MANUALPASSWORDREQUIRED (ERR_BASE-50)
  146.  
  147. #define ERR_END                            ERR_VLD8_MANUALPASSWORDREQUIRED    /* must be last error */
  148.  
  149.  
  150. #define kTemplateVers            1        /* current version understood by remote access for the connect template */
  151.  
  152. /* forward defs */
  153. typedef union TRemoteAccessParamBlock TRemoteAccessParamBlock;
  154. typedef TRemoteAccessParamBlock *TPRemoteAccessParamBlock;
  155.  
  156.  
  157. /* network transition */
  158. struct TNetworkTransition
  159. {
  160.     unsigned char                *privateVars;            /* pointer used internally by Remote Access */
  161.     NetValidProcPtr                netValidProc;            /* pointer to the network valid procedure */
  162.     Boolean                        newConnectivity;        /* set to true if new connectivity, false if loss of connectivity */
  163. };
  164. typedef struct TNetworkTransition TNetworkTransition;
  165. typedef TNetworkTransition *TPNetworkTransition;
  166.  
  167.  
  168. #define DControlParamHeader \
  169.     QElem                        *qLink;                    /*next queue entry*/\
  170.     short                        qType;                    /*queue type*/\
  171.     short                        ioTrap;                    /*routine trap*/\
  172.     Ptr                            ioCmdAddr;              /*routine address*/\
  173.     ProcPtr                        ioCompletion;            /*completion routine*/\
  174.     OSErr                        ioResult;                /*result code*/\
  175.     long                        userData;                /*for use by the user */\
  176.     short                        unused;                    /*unused field */\
  177.     short                        ioRefNum;                /*driver reference number*/\
  178.     short                        csCode;                    /*Call command code*/
  179.  
  180. #define DExtendedParam \
  181.     DControlParamHeader \
  182.     Ptr                            hReserved1; \
  183.     Ptr                            hReserved2; \
  184.     Ptr                            resultStrPtr; \
  185.     Ptr                            extendedType;            /* pointer to identifier string */
  186.  
  187.  
  188. #define DRemoteAccessParmHeader    \
  189.     DExtendedParam \
  190.     short                        extendedCode;            /* for use by extended call proc */\
  191.     Ptr                            portGlobalsPtr;            /* pointer to globals for this port (0=userport) */\
  192.  
  193.  
  194. struct TRemoteAccessParmHeader
  195. {
  196.     DRemoteAccessParmHeader
  197. };
  198. typedef struct TRemoteAccessParmHeader TRemoteAccessParmHeader;
  199.  
  200.  
  201. struct TRAConnectInfoTemplate
  202. {
  203.     unsigned long                version;                /* version of this format            */
  204.     unsigned long                ltType;                    /* Link Tool type                    */
  205.     long                        addressInfoLength;        /* length of the address information */
  206.     Ptr                            addressInfoPtr;            /* pointer to connect address info */
  207.     long                        ltSpecificTemplateLength;/* length of the ltspecific information */
  208.     Ptr                            ltSpecificTemplatePtr;    /* pointer to link tool specific params */
  209.     unsigned char                passWord[PASSWORDBUFSIZE];    /* user password                    */
  210.     unsigned char                userName[USERNAMESIZE];    /* user name                        */
  211.     unsigned long                connectReminderTimer;    /* value for connection    reminder in seconds    */
  212.     unsigned long                connectOKWaitTimer;        /* how long to wait for OK on reminder timer    */
  213.     Boolean                        guestLogin;                /* try to log in as a guest            */
  214.     Boolean                        passwordSaved;            /* set if password is saved            */
  215.     Boolean                        guaranteedAccess;        /* flag to guarantee access to servers internet */
  216.  
  217. };
  218. typedef struct TRAConnectInfoTemplate TRAConnectInfoTemplate;
  219. typedef TRAConnectInfoTemplate *TPRAConnectInfoTemplate;
  220.  
  221.  
  222. /* connect option flags
  223. */
  224. #define kNSCanInteract            0x00000001                // User interaction (password prompt) is OK 
  225. #define    kNSShowStatus            0x00000002                // show the status of the connect or disconnect call 
  226. #define    kNSConnectDocument        0x00000004                // connect using the specified document 
  227. #define    kNSPassWordSet            0x00000010                // use the specified password field when connecting by document 
  228. // 2.0 and above…
  229. #define kNS2SavvyFlags            0x40000000                // Set to use the next 2 flags below for only ARA 2.0 aware applications.
  230. #define    kNSAR2Connection        0x00000020                // connecting to a 2.0 server. 
  231. #define    kNSNotifyWhileConnected    0x00000040                // display cute notification icon while connected.
  232.  
  233. struct TRemoteAccessConnectParam
  234. {
  235.     DRemoteAccessParmHeader
  236.     TRAConnectInfoTemplate        connectInfo;            /* The connection infomation template */
  237.     unsigned long                optionFlags;            // bit mapped connect option flags 
  238.     FSSpec                        fileInfo;                // file info for connect document 
  239. };
  240. typedef struct TRemoteAccessConnectParam TRemoteAccessConnectParam;
  241.  
  242.  
  243. #define kNumWarnEntriesMax        5                        /* number of entries in warn array */
  244. struct TRemoteAccessDisconnectParam
  245. {
  246.     DRemoteAccessParmHeader
  247.     unsigned long                disconnectin;            /* server mode: disconnect in # of seconds */
  248.     TPRemoteAccessParamBlock    abortOnlyThisPB;        /* only abort a connection opened by this pb */
  249.     unsigned long                 warnArr[kNumWarnEntriesMax];    /* set warn times here in seconds (zero all if no warnings) */
  250.     unsigned long                optionFlags;            /* bit mapped connect option flags */
  251. };
  252. typedef struct TRemoteAccessDisconnectParam TRemoteAccessDisconnectParam;
  253.  
  254.  
  255. /* bits passed back in status call */
  256. #define CctlConnected                0x00000001        /* set when connected */
  257. #define CctlAnswerEnable            0x00000004        /* set when we are set to answer calls */
  258. #define CctlServerMode                0x00000008        /* set for server mode, clear for remote mode */
  259. #define CctlConnectionAborting        0x00000010        /* connection is being torn down */
  260. #define CctlConnectInProg            0x00000020        /* set when connection in progress or fully connected */
  261. #define CctlDisconnectInStarted        0x00008000        /* somebody has started a disconnectIn */
  262. #define    CctlGuestMode                0x00080000        /* set if this port is logged on with guest access */
  263. #define ctlAR2Connection            0x02000000        /* set when this connection is to a 2.0 server */
  264. #define ctlNotifyWhileConnected     0x04000000        /* set when the user wants to be reminded while connected */
  265. #define ctlConnectedToMPS           0x08000000        /* set when client is connected to a multi-port server */
  266. #define CctlMultiNodeReady            0x80000000        /* shows if we currently have a multinode address */
  267. struct TRemoteAccessStatusParam
  268. {
  269.     DRemoteAccessParmHeader
  270.     unsigned long                statusBits;                /* bits for current status */
  271.     unsigned long                timeConnected;            /* number of seconds we have been connected */
  272.     unsigned long                timeLeft;                /* number of seconds remaining in connection (0xffffffff infinite) */
  273.     unsigned char                *userNamePtr;            /* returns user name, expects pointer to buffer of USERNAMESIZE if non nil */
  274.     unsigned char                *connectedToNamePtr;    /* returns name of where we connected to, expects pointer to buffer of USERNAMESIZE if non nil */
  275.     TPRemoteAccessParamBlock    connectedByParamPtr;    /* a pointer to the parameter block "initiating" the connection if we are connected */    
  276.     TPRemoteAccessParamBlock    statusConnectedByParamPtr;    /* a pointer to the parameter block "initiating" the connection when status was posted */
  277.     unsigned char                *theLastStatusMsgPtr;    /* expects pointer to buffer of size MAXSTATUSMSGSIZE */
  278.     unsigned char                *statusUserNamePtr;        /* pointer to buffer of size USERNAMESIZE */
  279.     long                        statuslttype;            /* link tool type */
  280.     long                        statusmsgOptionFlags;    /* classification of message type */
  281.     long                        statusMsgNum;            /* specific message number */
  282.     long                        statusMsgSeqNum;        /* pass in zero if always want status, otherwise use last value, if status is new, new number is returned */
  283.     unsigned long                userSignature;            /* signature of port creator */
  284.     unsigned long                userRefCon;                /* refcon of port creator */
  285. };
  286. typedef struct TRemoteAccessStatusParam TRemoteAccessStatusParam;
  287.  
  288.  
  289. struct TRemoteAccessIsRemoteParms
  290. {
  291.     DRemoteAccessParmHeader
  292.     long                        theAddress;                /* address that is to be checked */
  293.     unsigned long                optionFlags;            /* Set to ctlir_getConnectInfo or ctlir_disposeConnectInfo, if zero only checks address */
  294.     Boolean                        locationIsRemoteFlag;    /* returns true    if address is remote */    
  295.     long                        ConnectInfoLength;        /* length of the following data */
  296.     TPRAConnectInfoTemplate        connectInfoPtr;            /* The connection information template pointer */
  297. };
  298. typedef struct TRemoteAccessIsRemoteParms TRemoteAccessIsRemoteParms;
  299.  
  300. struct TRemoteAccessPasswordMunger
  301. {
  302.     DRemoteAccessParmHeader
  303.     unsigned char                *userNamePtr;            /* pointer to username string */
  304.     unsigned char                *passWordPtr;            /* user password */    
  305.     unsigned short                reserved;                /* must set to zero */
  306. };
  307. typedef struct TRemoteAccessPasswordMunger TRemoteAccessPasswordMunger;
  308.  
  309.  
  310. struct TRemoteAccessGetCodeHooks
  311. {
  312.     DRemoteAccessParmHeader
  313.     RemmaperProcPtr                remapperProc;            /* quick vector to remapper code */
  314. };
  315.  
  316. typedef struct TRemoteAccessGetCodeHooks TRemoteAccessGetCodeHooks;
  317.  
  318. /* this is the union of all the different command types */
  319. union TRemoteAccessParamBlock
  320. {
  321.     TRemoteAccessParmHeader        HDR;                    /* header pb */
  322.     TRemoteAccessParmHeader        LOAD;                    /* load pb */
  323.     TRemoteAccessParmHeader        UNLOAD;                    /* unload pb */
  324.     TRemoteAccessConnectParam    CONNECT;                /* connect pb */
  325.     TRemoteAccessDisconnectParam DISCONNECT;            /* disconnect pb */
  326.     TRemoteAccessStatusParam    STATUS;                    /* get current status */
  327.     TRemoteAccessIsRemoteParms    ISREMOTE;                /* used to check network address location */
  328.     TRemoteAccessPasswordMunger    MUNGEPW;                /* run password through munger */
  329.     TRemoteAccessGetCodeHooks    CODEHOOKS;                /* get internal code hooks */
  330.  
  331.     unsigned char                filler[256];            /* set the minimum size of this parameter block */
  332. };
  333.  
  334. EXTERN_API ( OSErr ) PBRemoteAccess(TPRemoteAccessParamBlock paramBlock, Boolean async)
  335.     TWOWORDINLINE(0x7000,0xAA5B);
  336.  
  337. #if PRAGMA_STRUCT_ALIGN
  338.     #pragma options align=reset
  339. #elif PRAGMA_STRUCT_PACKPUSH
  340.     #pragma pack(pop)
  341. #elif PRAGMA_STRUCT_PACK
  342.     #pragma pack()
  343. #endif
  344.  
  345. #ifdef PRAGMA_IMPORT_OFF
  346. #pragma import off
  347. #elif PRAGMA_IMPORT
  348. #pragma import reset
  349. #endif
  350.  
  351. #ifdef __cplusplus
  352. }
  353. #endif
  354.  
  355. #endif /* __REMOTEACCESSINTERFACE__ */
  356.